﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using JackyCode.Mock.Exceptions;

namespace JackyCode.Mock
{
    public class MockData
    {   
        private IDictionary<MethodInfo, object> methodData;

        public IDictionary<MethodInfo, object> MethodData
        {
            get
            {
                if (methodData == null)
                {
                    methodData = new Dictionary<MethodInfo, object>();
                }
                return methodData;
            }
            internal set
            {
                methodData = value;
            }
        }

        public MockData(IDictionary<MethodInfo, object> methodData)
        {
            this.methodData = methodData;
        }

        public void Add(MethodInfo methodInfo, object returnVal)
        {
            MethodData.Add(methodInfo, returnVal);
        }

        public object GetValue(MethodInfo methodInfo)
        {
            if (methodInfo == null)
            {
                throw new ArgumentNullException("The methodInfo can't be null!");
            }

            if (!methodData.ContainsKey(methodInfo))
            {
                throw new MockException("Never set up any information about the methodInfo");
            }

            return methodData[methodInfo];
        }
    }
}
